//package com.example.wxy2.service.impl;
//
//import com.alibaba.fastjson.JSON;
//import com.example.wxy.controller.dto.loginDto;
//import com.example.wxy.entity.Result;
//import com.example.wxy.entity.login;
//import com.example.wxy.service.SysUserService;
//import com.example.wxy.service.loginService;
//import com.example.wxy.utils.Jwtutils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.Resource;
//import java.util.concurrent.TimeUnit;
//
//@Service
//public class loginServiceImpl implements loginService {
//
//    @Resource
//    private login login;
//
//    @Autowired SysUserService sysUserService;
//
//    @Autowired
//    private RedisTemplate<String,String> redisTemplate;
//
////    private static final String slat = "mszlu!@#";
//    @Override
//    public Result login(loginDto logindto) {
//        System.out.println(logindto);
////        QueryWrapper<login> queryWrapper = new QueryWrapper<>();
////        queryWrapper.eq("username", logindto);
////        queryWrapper.eq("pwd", logindto.getPwd());
//        String username = logindto.getUsername();
//        String password = logindto.getPwd();
//        if(username == null || password == null ){
//            return Result.fail(10001, "参数不合法");
//        }
//        //密码加密，设置加密言
////        password = DigestUtils.md5Hex(password + slat);
//        login user = sysUserService.findUser(username, password);
//        if(user == null){
//            return Result.fail(1002,"用户名或密码不存在");
//        }
//        String token = Jwtutils.createToken(user.getId());
//        //过期时间一天
//        redisTemplate.opsForValue().set("TOKEN_"+token, JSON.toJSONString(user),1, TimeUnit.DAYS);
//        return Result.success(token);
//    }
//}
